package com.asm.server.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class LifeCycleTestHandlerInbound extends ChannelInboundHandlerAdapter {
    public static void main(String[] args) throws Exception {
        LifeCycleTestHandlerInbound h = new LifeCycleTestHandlerInbound();
        h.channelRegistered(null);
    }
    public LifeCycleTestHandlerInbound() {
        super();


    }

    @Override
    public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
        log.debug("=====>>{} ...", new RuntimeException().getStackTrace()[0].getMethodName());
        super.handlerAdded(ctx);
    }

    @Override
    public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
        log.debug("=====>>{} ...", new RuntimeException().getStackTrace()[0].getMethodName());
        super.handlerRemoved(ctx);
    }

    @Override
    public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
        StackTraceElement[] stackTraceElements = new RuntimeException().getStackTrace();
        log.debug("=====>>{} ...", stackTraceElements[0].getMethodName());
        super.channelRegistered(ctx);
    }

    @Override
    public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
        log.debug("=====>>{} ...", new RuntimeException().getStackTrace()[0].getMethodName());
        super.channelUnregistered(ctx);
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        log.debug("=====>>{} ...", new RuntimeException().getStackTrace()[0].getMethodName());
        super.channelActive(ctx);
    }

    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        log.debug("=====>>{} ...", new RuntimeException().getStackTrace()[0].getMethodName());
        super.channelInactive(ctx);
    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        log.debug("=====>>{} ...", new RuntimeException().getStackTrace()[0].getMethodName());
        super.channelRead(ctx, msg);
    }

    @Override
    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
        log.debug("=====>>{} ...", new RuntimeException().getStackTrace()[0].getMethodName());
        super.channelReadComplete(ctx);
    }

    @Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
        log.debug("=====>>{} ...", new RuntimeException().getStackTrace()[0].getMethodName());
        super.userEventTriggered(ctx, evt);
    }

    @Override
    public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
        log.debug("=====>>{} ...", new RuntimeException().getStackTrace()[0].getMethodName());
        super.channelWritabilityChanged(ctx);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        log.debug("=====>>{} ...", new RuntimeException().getStackTrace()[0].getMethodName());
        super.exceptionCaught(ctx, cause);
    }
}
